import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderVO, OrderForm, OrderQuery } from '@/api/primary/order/types';

/**
 * 查询订单信息列表
 * @param query
 * @returns {*}
 */

export const listOrder = (query?: OrderQuery): AxiosPromise<OrderVO[]> => {
  return request({
    url: '/primary/order/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询财务列表
 * @param query
 * @returns {*}
 */

export const reportFormsOrder = (query?: OrderQuery): AxiosPromise<OrderVO[]> => {
  return request({
    url: '/primary/order/revenueData',
    method: 'get',
    params: query
  });
};
/**
 * 查询订单信息详细
 * @param id
 */
export const getOrder = (id: string | number): AxiosPromise<OrderVO> => {
  return request({
    url: '/primary/order/' + id,
    method: 'get'
  });
};

/**
 * 新增订单信息
 * @param data
 */
export const addOrder = (data: OrderForm) => {
  return request({
    url: '/primary/order/place',
    method: 'post',
    data: data
  });
};
/**
 * 获取支付链接
 * @param data
 */
export const addOrderpay = (data: OrderForm) => {
  return request({
    url: '/primary/order/pay',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单信息
 * @param data
 */
export const updateOrder = (data: OrderForm) => {
  return request({
    url: '/primary/order',
    method: 'put',
    data: data
  });
};

/**
 * 删除订单信息
 * @param id
 */
export const delOrder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/primary/order/' + id,
    method: 'delete'
  });
};

/**
 * 退款审核
 * @param data
 */
export const refundOrder = (data: any) => {
  return request({
    url: '/primary/order/check',
    method: 'post',
    data: data
  });
};
/**
 * 查询订单信息详细2
 * @param query
 * @returns {*}
 */

export const getpie = (query?: OrderQuery): AxiosPromise<OrderVO[]> => {
  return request({
    url: '/primary/order/salesPerformance',
    method: 'get',
    params: query
  });
};

export const getFlow = (query?: OrderQuery): AxiosPromise<OrderVO[]> => {
  return request({
    url: '/primary/signIn/flow',
    method: 'get',
    params: query
  });
};
